package com.example.ormsqlsplicingframe1.warpper;

import com.example.ormsqlsplicingframe1.proxy.RouteSession;
import com.example.ormsqlsplicingframe1.utlis.ProxySessionUtils;

import java.util.List;

public interface IntegrationImplementsWrapper<E extends IntegrationImplementsWrapper<E>> {

    default UpdateSqlWrapper<E> update(){
        return UpdateSqlWrapper.newInstance((E)this);
    }
    default InsertSqlWrapper insert(){
        return InsertSqlWrapper.newInstance((E)this);
    }

    //获取一个代理对象
    default E createSyncProxy(){
        return ProxySessionUtils.route().proxyObject((E) this);
    }

    default List<E> getProxyList(){
        return ProxySessionUtils.route().getList((E) this);
    }

    default void commitUpdate(){
        ProxySessionUtils.route().commitTransaction();
    }

}
